// 处理上传附件
export const filterUploadList = (list = []) => {
  const fileList = {}
  list.forEach(element => {
    const { processId } = element
    const proceeList = fileList[processId] || []
    proceeList.push(element)
    fileList[processId] = proceeList
  })
  return fileList
}

export const filterRouter = (userRouter = [], allRouter = []) => {
  const roleFilterArr = allRouter
    .filter(item => userRouter.includes(item.name)) // 过滤第一级路由
    .map(item => ({
      ...item,
      children: item.children ? filterRouter(userRouter, item.children) : null
    }))
  return roleFilterArr
}

// 菜单过滤
export const filterRouterByParent = (menus = [], parentId) => {
  const newMenus = menus.filter(item => {
    if (item.parentId === parentId && item.type !== 2) {
      item.children = filterRouterByParent(menus, item.menuId)
      return item
    }
  })
  return newMenus
}
